<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>


</head>
<body>
<h3>0001</h3>
<h3>0002</h3>
<h3>0003</h3>
<h3>0004</h3>
<h3>0005</h3>
<h3>0006</h3>
<h3>0007</h3>
<h3>0008</h3>
<h3>0009</h3>
<h3>0010</h3>
<h3>0011</h3>
<h3>0012</h3>
<h3>0013</h3>
<h3>0014</h3>
<h3>0015</h3>
<h3>0016</h3>
<h3>0017</h3>
<h3>0018</h3>
<h3>0019</h3>
<h3>0020</h3>
<h3>0021</h3>
<h3>0022</h3>
<h3>0023</h3>
<h3>0024</h3>
<h3>0025</h3>
<h3>0026</h3>
<h3>0027</h3>
<h3>0028</h3>
<h3>0029</h3>
<h3>0030</h3>
<div class="a">
    <img src="" data-src="https://extraimage.net/images/2019/04/24/a23e9bbb0a272ac6168f5901372b8435.jpg" alt="">
</div>

 
</body>
<script src="jquery-3.3.1.min.js"></script>
<script src="jquery.min.js"></script>
<script>
  $(function () {
      var windowheight = $(window).height();
      var scrollTop =$(document).scrollTop();

      $(window).on('resize',function () {
          windowheight = $(window).height();
      });
      var detect = function (){
          if ($(className).length === 0) {
              $(document).off('scroll',detect);
          }


      }
      $(document).on('scroll',function () {
          var $self = $(this);
          $(className).each(function () {
              var posY = $(this).offset().top;
              scrollTop =$(document).scrollTop();
              var _distance = posY - scrollTop-windowheight;
              if (_distance <= 0) {
                  $(this).find('img').attr('src',$('.a >img').attr('data-src'));
                  var originClassName = $(this).attr('class');
                  $(this).attr('class',originClassName.replace(new RegExp(className.substr(1)),''))


           }
          });

      })

  })
</script>
</html>